package com.unsins.core.basedomain;

import org.springframework.dao.DataAccessException;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: odpsoft
 * Date: 2008-11-27
 * Time: 11:19:00
 * To change this template use File | Settings | File Templates.
 */
public interface IEntityRepository<T> {
    T get(Serializable id);

    List<T> getAll();

    void save(Object o);

    void remove(Object o);

    void removeById(Serializable id);

    /**
     * 获取Entity对象的主键名.
     */
    @SuppressWarnings("unchecked")
    String getIdName(Class clazz);

    /**
     * 根据keyName＝keyValue，查询得到list然后返回
     *
     * @param entity Class
     *               entity
     * @param keymap keyName String,keyValue Object
     * @return Object
     * @throws DataAccessException
     */
    @SuppressWarnings("unchecked")
    public List<T> findAllByMapKey(Class entity, Map<String, String> keymap)
            throws DataAccessException;

    @SuppressWarnings("hiding")
    public List<T> findBy(String hql, Object... values);
}
